<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      height: 100vh;
      background-color: black;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }

    .box {
      width: 200px;
      /* height: 100px; */
      background: white;
    }

    .ball {
      width: 30px;
      height: 30px;
      background: red;
      border-radius: 50%;
      animation: go .5s;
    }

    .ball:nth-child(1) {
      animation-fill-mode: forwards;
    }

    .ball:nth-child(3) {
      animation-fill-mode: backwards;
     
    }
    .ball:nth-child(3),
    .ball:nth-child(4) {
      animation-direction: reverse;
      animation-delay: 1s;
    }

    @keyframes go {
      to {
        transform: translateX(100px);
      }
    }
  </style>
</head>
<body>
  <p>
    forword表示，将元素会停留在最后一帧，根据方向和次数最后一帧会有所不同
    backword表示，会将第一帧应用在元素上，延迟期间也会保留该值（否则只有等到动画开始了才会跳到第一帧），由方向来判断第一帧
    这里注意，如果延迟为0得话，backword则与默认得效果没什么区别，
    both则同时使用这两个规则
  </p>
  <div class="box">
    <div class="ball"></div>
    <div class="ball"></div>
    <div class="ball"></div>
    <div class="ball"></div>
  </div>
</body>
</html>